package com.stars.easyms.logger.support.commons.logging;

import org.apache.commons.logging.Log;
import org.slf4j.Logger;

/**
 * <p>className: EasyMsCommonsLog</p>
 * <p>description: commons-logging的日志类</p>
 *
 * @author guoguifang
 * @date 2019-11-12 13:33
 * @since 1.3.3
 */
public final class EasyMsCommonsLog implements Log {

    private final Logger logger;

    public EasyMsCommonsLog(Logger logger) {
        this.logger = logger;
    }

    @Override
    public boolean isFatalEnabled() {
        return logger.isErrorEnabled();
    }

    @Override
    public boolean isErrorEnabled() {
        return logger.isErrorEnabled();
    }

    @Override
    public boolean isWarnEnabled() {
        return logger.isWarnEnabled();
    }

    @Override
    public boolean isInfoEnabled() {
        return logger.isInfoEnabled();
    }

    @Override
    public boolean isDebugEnabled() {
        return logger.isDebugEnabled();
    }

    @Override
    public boolean isTraceEnabled() {
        return logger.isTraceEnabled();
    }

    @Override
    public void fatal(Object message) {
        if (logger.isErrorEnabled()) {
            logger.error(String.valueOf(message));
        }
    }

    @Override
    public void fatal(Object message, Throwable t) {
        if (logger.isErrorEnabled()) {
            logger.error(String.valueOf(message), t);
        }
    }

    @Override
    public void error(Object message) {
        if (logger.isErrorEnabled()) {
            logger.error(String.valueOf(message));
        }
    }

    @Override
    public void error(Object message, Throwable t) {
        if (logger.isErrorEnabled()) {
            logger.error(String.valueOf(message), t);
        }
    }

    @Override
    public void warn(Object message) {
        if (logger.isWarnEnabled()) {
            logger.warn(String.valueOf(message));
        }
    }

    @Override
    public void warn(Object message, Throwable t) {
        if (logger.isWarnEnabled()) {
            logger.warn(String.valueOf(message), t);
        }
    }

    @Override
    public void info(Object message) {
        if (logger.isInfoEnabled()) {
            logger.info(String.valueOf(message));
        }
    }

    @Override
    public void info(Object message, Throwable t) {
        if (logger.isInfoEnabled()) {
            logger.info(String.valueOf(message), t);
        }
    }

    @Override
    public void debug(Object message) {
        if (logger.isDebugEnabled()) {
            logger.debug(String.valueOf(message));
        }
    }

    @Override
    public void debug(Object message, Throwable t) {
        if (logger.isDebugEnabled()) {
            logger.debug(String.valueOf(message), t);
        }
    }

    @Override
    public void trace(Object message) {
        if (logger.isTraceEnabled()) {
            logger.trace(String.valueOf(message));
        }
    }

    @Override
    public void trace(Object message, Throwable t) {
        if (logger.isTraceEnabled()) {
            logger.trace(String.valueOf(message), t);
        }
    }
}